<template>
  <el-container id ="home-page">
    <!--  页头  -->
    <el-header>
      <div id="home-header">
        <img src="@/assets/logo.png" alt="" id="logo"/>
        <span>WElCOME TO VUE3</span>
      </div>
      <el-button type="info" @click="logout">退出</el-button>
    </el-header>

    <el-container>
      <!-- 侧栏菜单-->
      <el-aside width="200px">
        <el-menu
            id = "home-menu"
            default-active="/home"
            class="el-menu-vertical-demo"
            background-color="#333744"
            text-color="#fff"
            active-text-color="#ffd04b"
            :router="true"
        >
          <el-menu-item index="/home">
            <el-icon><Position /></el-icon>
            <i class="el-icon-document"></i>
            <span>导航一</span>
          </el-menu-item>

          <el-menu-item index="/test1" >
            <el-icon><location /></el-icon>
            <i class="el-icon-setting"></i>
            <span>导航二</span>
          </el-menu-item>

          <el-menu-item index="/test2">
            <el-icon><document /></el-icon>
            <i class="el-icon-document"></i>
            <span>导航三</span>
          </el-menu-item>

          <!--    二级菜单 有需要自己配置      -->
          <!--          <el-sub-menu index="/test2">-->
          <!--            <template #title>-->
          <!--              <el-icon><document /></el-icon>-->
          <!--              <span>导航三</span>-->
          <!--            </template>-->
          <!--            <el-menu-item-group >-->
          <!--              <el-menu-item index="1-1">item one</el-menu-item>-->
          <!--              <el-menu-item index="1-2">item two</el-menu-item>-->
          <!--            </el-menu-item-group>-->
          <!--          </el-sub-menu>-->

        </el-menu>
      </el-aside>

      <el-container>
        <!-- 内容-->
        <el-main>
          <router-view />
        </el-main>
      </el-container>

    </el-container>

  </el-container>
</template>

<script>
export default {
  name: "MyMenu",
  methods:{
    logout(){
      // 移除登录信息
      localStorage.removeItem("loginData");
      this.$router.push({name:'login'})
    }
  }
}
</script>

<style scoped>

#home-header{
  display: flex;
  align-items: center;
}
#logo{
  height: 40px;
  width: 40px;
  margin-right: 10px;
}
#home-page{
  height: 100% ;
  width: 100% ;
}
#home-menu{
  height: 100%;
  width: 100%;
}
.el-header {
  background-color: #373d41;
  color: white;
  display: flex;
  justify-content: space-between;
  padding-left: 0;
  align-items: center;
  font-size: 20px;
  text-align: center;
  line-height: 60px;

}

.el-aside {
  text-align: center;
  line-height: 200px;
  height: 100vh;
}

.el-main {
  background-color: #E9EEF3;
  color: #333;
  text-align: center;
  line-height: 160px;
}
</style>